<?php

/**
 * Result filter form base class.
 *
 * @package    question_answer
 * @subpackage filter
 * @author     Your name here
 */
abstract class BaseResultFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'question_id' => new sfWidgetFormFilterInput(),
      'answer_id'   => new sfWidgetFormFilterInput(),
      'user_id'     => new sfWidgetFormFilterInput(),
      'point'       => new sfWidgetFormFilterInput(),
      'check'       => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'create_at'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'question_id' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'answer_id'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'user_id'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'point'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'check'       => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'create_at'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('result_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Result';
  }

  public function getFields()
  {
    return array(
      'id'          => 'Number',
      'question_id' => 'Number',
      'answer_id'   => 'Number',
      'user_id'     => 'Number',
      'point'       => 'Number',
      'check'       => 'Boolean',
      'create_at'   => 'Date',
    );
  }
}
